<template>
<div class="table">
    <div class="crumbs">
        <el-breadcrumb separator="/">
            <el-breadcrumb-item><i class="el-icon-tickets"></i>项目</el-breadcrumb-item>
        </el-breadcrumb> 
    </div>
    <div class="container">
        <div class="handle-box">
            <el-input v-model="select_table" placeholder="表名" class="handle-input mr10"></el-input>
            <el-button type="primary" icon="search" @click="search">搜索</el-button>
            <el-button type="primary" icon="search" @click="creatObject" style="float:right">新建</el-button>
        </div>
        <el-table :data="tableData" border style="width: 100%">
            <el-table-column type="selection" width="30"></el-table-column>
            <el-table-column prop="tableName" label="工程名称" sortable ></el-table-column>
            <el-table-column prop="engine" label="默认包" ></el-table-column>
            <el-table-column prop="engine" label="工程作者" ></el-table-column>
            <el-table-column prop="engine" label="工程作者email" ></el-table-column>
            <el-table-column prop="engine" label="表前缀" ></el-table-column>
            <el-table-column prop="engine" label="模块名" ></el-table-column>
            <el-table-column prop="createTime" label="创建时间" ></el-table-column>
            <el-table-column label="操作" >
                <template slot-scope="scope">
                    <el-button size="small" >编辑</el-button>
                    
                </template>
            </el-table-column>
        </el-table>
        <div class="pagination">
            <el-pagination @current-change="handleCurrentChange" layout="total,prev, pager, next" :total="totalPage"/>
        </div>
    </div>
    <el-dialog title="编辑" :visible.sync="editVisible" width="30%">
        <el-form ref="form"  label-width="50px">
            <el-form-item label="日期">
                <el-date-picker type="date" placeholder="选择日期"   style="width: 100%;"></el-date-picker>
            </el-form-item>
            <el-form-item label="姓名">
                <el-input  ></el-input>
            </el-form-item>
            <el-form-item label="地址">
                <el-input  ></el-input>
            </el-form-item>
        </el-form>
    </el-dialog>
</div>
</template>

<script>
export default {
  data() {
    return {
      select_table :'',
       editVisible: false,
      cur_page :1,
      tableData: [],
      limit:10,
      totalPage :10
    };
  },
    created() {
       // this.getData();
    },
    computed: {

    },
     methods: {
         testData (url,params){
           return this.$axios.get(url, {params: params})
    //         return new Promise((resolve, reject) => {
    //     _axios
    //         .get(url, {
    //             params: params
    //         }).then(res => {
    //            resolve(res.data)
    //         }).catch(err => {
    //             console.log(err.data)  
    //         })
    // })
         },
         async getData() {
             try{
                 let res=await  this.$api.listTables5({
                        t: 10,
                        t2:3
                    })
              console.log(res)
             console.log('==============')

             }catch(e){
                //console.log(e)
             }

             //.then(res=>{console.log(res)})
            // this.$api.listTables3({
            //     page: this.cur_page,
            //     limit :this.limit  
            // }).then((res) => {
            //     console.log(res)
            // })
            //  this.$apis.listTables({
            //         page: this.cur_page, 
            //         limit :this.limit
            //         })
            // this.$axios.get(this.urlList, {
            //     params: {
            //         page: this.cur_page,
            //         limit :this.limit
            //         }
            // }).then((res) => {
            //     this.tableData = res.data.page.list;
            //     this.totalPage=res.data.page.totalPage;
            // })
           // this.testData(this.urlList, {page: this.cur_page,limit :this.limit}
          //  ).then(data=>{console.log('=0=====',data) }).catch();
         },
         async createProject(){
             try{
                await this.$api.cerateProject({});

             }catch(e){

             }

         },
         creatObject(){
            this.editVisible = true;
         },
        handleCurrentChange(val) {
            this.cur_page = val;
            this.getData();
        },
        search() {
            this.$axios.get(this.urlList, { 
                params: {
                    tableName:this.select_table,
                    page: 1,
                    limit :this.limit
                    }
            }).then((res) => {
                this.tableData = res.data.page.list;
                this.totalPage=res.data.page.totalPage;
            }).catch(e => {
              // 打印一下错误
              console.log(e)
          })
        }
     },
     // 分页导航
   
};
</script>

<style>
.handle-box {
  margin-bottom: 20px;
}

.handle-select {
  width: 120px;
}

.handle-input {
  width: 250px;
  display: inline-block;
}
.del-dialog-cnt {
  font-size: 16px;
  text-align: center;
}
</style>
